HTML - tags - pre tag

revision:


Content

"pre" tag : preformatted text tag syntax some examples


"pre" tag : preformatted text tag

top

The <pre> tag defines preformatted text. Text in a <pre> element is displayed in a fixed-width font, and the text preserves both spaces and line breaks. The text will be displayed exactly as written in the HTML source code.

Attributes: the <pre> element supports the global attributes and events attributes.


syntax

top

<pre> . . . </pre>


some examples

top
                    Text in a pre element
                    is displayed in a fixed-width
                    font, and it preserves
                    both      spaces and
                    line breaks
                
Codes:
                    <pre>
                        Text in a pre element
                        is displayed in a fixed-width
                        font, and it preserves
                        both      spaces and
                        line breaks
                    </pre>
                        
                

Standard pre

This is a standard pre. It will use as much space as it needs.

Fixed width pre

This is a pre with a fixed width. It will use as much space as specified.
Codes:
                    <h4>Standard pre</h4>
                    <pre>This is a standard pre. It will use as much space as it needs.</pre>
                    <h4>Fixed width pre</h4>
                    <div style="width:200px;overflow:auto;margin-left:1vw;">
                        <pre>This is a pre with a fixed width. It will use as much space as specified.</pre>
                    </div>